home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-08 | 3.0 KB | 127 lines | [TEXT/CCL2] |
- ;;; -*- package: CC -*-
- ;;;
- ;;;; Tools for the extended apropos
- ;;;
-
-
- (in-package "CC")
-
-
- ;;;
- ;;;; Selection pop up
- ;;;
-
-
- (defclass selection-pop-up (pop-up-menu)
- ((list :initarg :list :initform nil)
- (menu-item-action :initarg :menu-item-action :initform nil)))
-
-
- (defclass selection-menu-item (menu-item)
- ((value :initarg :value)))
-
-
- (defmethod selected-item ((self selection-pop-up))
- (slot-value (call-next-method)
- 'value))
-
-
- (defmethod initialize-instance :after ((self selection-pop-up) &key)
- (with-slots (list menu-item-action) self
- (apply (function add-menu-items) self
- (iter (for (value text) in list)
- (collect
- (if (and (null value)
- (null text))
- (make-instance 'menu-item
- :menu-item-title "-")
- (make-instance 'selection-menu-item
- :value value
- :menu-item-title text
- :menu-item-action
- (function
- (lambda ()
- (when menu-item-action
- (funcall menu-item-action))
- (auto-search-action))))))))))
-
-
- ;;;
- ;;;; Contour mixin
- ;;;
-
-
- (defclass apropos-contour-view (view)
- ())
-
-
- (defmethod install-view-in-window :after ((self apropos-contour-view) window)
- (declare (ignore window))
- (set-view-size self (apropos-contour-size (subviews self))))
-
-
- (defun apropos-contour-size (views)
- (iter (for view in views)
- (for pos = (view-position view))
- (for size = (or (view-size view) (view-default-size view)))
- (for left = (point-h pos))
- (for top = (point-v pos))
- (for right = (+ left (point-h size)))
- (for bottom = (+ top (point-v size)))
- (minimizing left into min-left)
- (minimizing top into min-top)
- (maximizing right into max-right)
- (maximizing bottom into max-bottom)
- (finally (return (make-point (+ 5 min-left max-right)
- (+ min-top max-bottom))))))
-
-
- ;;;
- ;;;; A window that hides when closed
- ;;;
-
-
- (defclass apropos-hide-window (window)
- ())
-
-
- (defvar *apropos-force-close* nil)
-
-
- (defmethod window-close :around ((window apropos-hide-window))
- (if *apropos-force-close*
- (call-next-method)
- (window-hide window)))
-
- (defmethod window-apropos-force-close ((window apropos-hide-window))
- (let ((*apropos-force-close* t))
- (window-close window)))
-
-
- ;;;
- ;;;; Various
- ;;;
-
-
- (defun compatible-modifiers ()
- (list (shift-key-p)
- (or (control-key-p)
- (command-key-p))
- (option-key-p)))
-
-
- (defun inverse (predicate)
- (function
- (lambda (x)
- (not (funcall predicate x)))))
-
-
- (defmethod find-view ((view view) name)
- (labels ((find-aux (subview)
- (if (eql (view-nick-name subview) name)
- (return-from find-view subview)
- (do-subviews (x subview)
- (find-aux x)))))
- (find-aux view)
- nil))
-